<template>
  <div>
    <!-- title -->
    <PageTitle>
      {{ $t("menu.M_10400402") }}
    </PageTitle>
    <!-- body -->
    <el-card
      shadow="never"
      :body-style="{ padding: '0px' }"
      :page-size="pageSize"
      :total="rows"
      :current-page="pageNo"
      @current-change="currentChangeHandle"
    >
      <el-form class="p-4" inline :model="dataForm">
        <!--      <el-form-item>
                    <el-input v-model="dataForm.name" :placeholder="$t('developer.name')" clearable></el-input>
                  </el-form-item>-->
        <el-form-item>
          <el-input
            v-model="dataForm.name"
            maxlength="32"
            :placeholder="$t('developer.search_name')"
            clearable
            @blur="() => (dataForm.name = dataForm.name.trim())"
            @clear="getDataList((pageNo = 1))"
          />
        </el-form-item>
        <el-form-item>
          <el-select
            v-model="dataForm.status"
            clearable
            :placeholder="$t('developer.status')"
          >
            <el-option
              v-for="item in statusArray"
              :key="item.value"
              :value="item.value"
              :label="item.label"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-select
            v-model="dataForm.developerType"
            clearable
            :placeholder="$t('developer.developerType')"
          >
            <el-option
              v-for="item in typeArray"
              :key="item.value"
              :value="item.value"
              :label="item.label"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" class="w-8" @click="getDataList((pageNo = 1))">
            <svg-icon icon-class="search" />
          </el-button>
        </el-form-item>

        <el-form-item style="float: right">
          <el-button type="primary" class="w-8">
            <table-column-filter
              :list="settingList"
              :default-setting="defaultSettings"
              v-model:settings="settings"
              domain="developer.list"
            />
          </el-button>
        </el-form-item>
        <el-form-item>
          <el-button
            v-if="isAuth('10400402.MANAGE')"
            type="primary"
            class="w-8"
            @click="manageNoticeEmail"
          >
            <svg-icon icon-class="Message" />
          </el-button>
        </el-form-item>
        <el-form-item>
          <el-button
            v-if="isAuth('10400402.MANAGE')"
            type="primary"
            class="w-8"
            @click="handleCommandAdd"
          >
            <svg-icon icon-class="Plus" />
          </el-button>
        </el-form-item>
        <el-form-item>
          <el-dropdown trigger="click" @command="handleCommandImport">
            <el-button v-if="isAuth('10400402.MANAGE')" type="primary" class="w-8">
              <svg-icon icon-class="batch-add" />
            </el-button>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item command="Personal">{{
                  $t("developer.developer_type_list.personal")
                }}</el-dropdown-item>
                <el-dropdown-item command="Company">{{
                  $t("developer.developer_type_list.company")
                }}</el-dropdown-item>
              </el-dropdown-menu></template
            >
          </el-dropdown>
        </el-form-item>
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" stripe>
        <el-table-column prop="name" :label="$t('developer.name')">
          <template v-slot="scope">
            <div @click="handleDetail(scope.row)">
              <label
                v-if="scope.row.developerType === 1"
                type="text"
                class="cursor-pointer"
                >{{ scope.row.contactName }}</label
              >
              <label
                v-if="scope.row.developerType === 2"
                type="text"
                class="cursor-pointer"
                >{{ scope.row.firstName }}</label
              >
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="developerType" :label="$t('developer.developerType')">
          <template v-slot="scope">
            <el-tag v-if="scope.row.developerType === 1" type="text" size="small">
              {{ $t("developer.developer_type_list.personal") }}
            </el-tag>
            <el-tag v-if="scope.row.developerType === 2" type="text" size="small">
              {{ $t("developer.developer_type_list.company") }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column
          v-if="showHeader('pidType')"
          key="pidType"
          prop="pidType"
          :label="$t('developer.pidType')"
        >
          <template v-slot="scope">
            <el-tag
              v-if="scope.row.developerType === 1 && scope.row.pidType"
              type="text"
              size="small"
            >
              {{
                scope.row.pidType === 1
                  ? $t("developer.id_card")
                  : scope.row.pidType === 2
                  ? $t("developer.passport")
                  : $t("developer.unknown")
              }}
            </el-tag>
            <el-tag
              v-if="scope.row.developerType === 2 && scope.row.pidType"
              type="text"
              size="small"
            >
              {{ $t("developer.business_license") }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column
          v-if="showHeader('pidNo')"
          key="pidNo"
          prop="pidNo"
          :label="$t('developer.pidNo')"
        />
        <el-table-column
          v-if="showHeader('email')"
          key="email"
          prop="email"
          :label="$t('developer.email')"
        />
        <el-table-column prop="status" min-width="100" :label="$t('developer.status')">
          <template v-slot="scope">
            <el-tag v-if="scope.row.status === 2" size="small" type="warning">
              {{ statusFilter(scope.row.status) }}
            </el-tag>
            <el-tag v-if="scope.row.status === 1" size="small" type="success">
              {{ statusFilter(scope.row.status) }}
            </el-tag>
            <el-tag
              v-if="scope.row.status === 5 || scope.row.status === 7"
              size="small"
              type="info"
            >
              {{ statusFilter(scope.row.status) }}
            </el-tag>
            <el-tag
              v-if="
                scope.row.status === 0 || scope.row.status === 3 || scope.row.status === 8
              "
              size="small"
              type="danger"
            >
              {{ statusFilter(scope.row.status) }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column
          v-if="showHeader('creTime')"
          key="creTime"
          prop="creTime"
          min-width="100"
          :label="$t('developer.creTime')"
        >
          <template v-slot="scope">
            <div :title="timeFilter(scope.row.creTime)">
              {{ dateFilter(scope.row.creTime) }}
              {{ scope.row.creTime ? "" : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          v-if="showHeader('remark')"
          key="remark"
          prop="remark"
          min-width="100"
          :label="$t('contact.remark')"
        />
        <el-table-column
          v-if="showHeader('rejectionReason')"
          key="rejectionReason"
          prop="rejectionReason"
          min-width="100"
          :label="$t('common.reject_reason')"
        />
        <el-table-column width="75px">
          <template v-slot="scope">
            <el-dropdown
              @command="
                (command) => {
                  handleDevCommand(command, scope.row);
                }
              "
            >
              <el-button text class="w-8">
                <svg-icon icon-class="MoreFilled" />
              </el-button>
              <template #dropdown>
                <el-dropdown-menu>
                  <el-dropdown-item command="info">
                    {{ $t("developer.operate_detail") }}
                  </el-dropdown-item>
                  <el-dropdown-item v-if="isAuth('10400402.MANAGE')" command="remark">
                    {{ $t("contact.remark") }}
                  </el-dropdown-item>
                  <el-dropdown-item
                    v-if="scope.row.status === 2 && isAuth('10400402.MANAGE')"
                    command="apply"
                  >
                    {{ $t("developer.operate_apply_cert") }}
                  </el-dropdown-item>
                  <el-dropdown-item
                    v-if="scope.row.status === 7 && isAuth('10400402.MANAGE')"
                    command="download"
                  >
                    {{ $t("developer.operate_download_cert") }}
                  </el-dropdown-item>
                  <el-dropdown-item
                    v-if="scope.row.status === 1 && isAuth('10400402.MANAGE')"
                    command="lock"
                  >
                    {{ $t("developer.operate_lock") }}
                  </el-dropdown-item>
                  <el-dropdown-item
                    v-if="scope.row.status === 0 && isAuth('10400402.MANAGE')"
                    command="unlock"
                  >
                    {{ $t("developer.operate_unlock") }}
                  </el-dropdown-item>
                  <el-dropdown-item
                    v-if="
                      (scope.row.status === 2 || scope.row.status === 8) &&
                      isAuth('10400402.MANAGE')
                    "
                    command="delete"
                  >
                    {{ $t("developer.operate_delete") }}
                  </el-dropdown-item>
                  <el-dropdown-item
                    v-if="scope.row.status === 1 && isAuth('10400402.MANAGE')"
                    command="close"
                  >
                    {{ $t("developer.operate_close") }}
                  </el-dropdown-item>
                  <el-dropdown-item
                    v-if="scope.row.status === 7 && isAuth('10400402.MANAGE')"
                    command="examine"
                  >
                    {{ $t("developer.operate_examine") }}
                  </el-dropdown-item>
                  <el-dropdown-item
                    v-if="scope.row.status === 2 && isAuth('10400402.MANAGE')"
                    command="reject"
                  >
                    {{ $t("developer.operate_reject") }}
                  </el-dropdown-item>
                  <el-dropdown-item
                    v-if="isAuth('10400402.MANAGE')"
                    command="auditRecordList"
                  >
                    {{ $t("developer.audit_record.list_title") }}
                  </el-dropdown-item>
                  <!--                <el-dropdown-item-->
                  <!--                  command="showCheckAssist"-->
                  <!--                  v-if="scope.row.status === 2 && isAuth('10400402.MANAGE')"-->
                  <!--                >-->
                  <!--                  <span class="text-center">{{-->
                  <!--                    $t('developer.operate_audit_assist')-->
                  <!--                  }}</span>-->
                  <!--                </el-dropdown-item>-->
                  <!--                <el-dropdown-item-->
                  <!--                  command="showCheckAssistResult"-->
                  <!--                  v-if="scope.row.status !== 5 && isAuth('10400402.MANAGE')"-->
                  <!--                >-->
                  <!--                  <span class="text-center">{{-->
                  <!--                    $t('developer.operate_audit_assist_result')-->
                  <!--                  }}</span>-->
                  <!--                </el-dropdown-item>-->
                  <!--                <el-dropdown-item-->
                  <!--                  command="manageUsbKey"-->
                  <!--                  v-if="scope.row.status === 1 && isAuth('10400402.MANAGE')"-->
                  <!--                >-->
                  <!--                  <span class="text-center">-->
                  <!--                    {{ $t('developer.operate_manage_usb_key') }}-->
                  <!--                  </span>-->
                  <!--                </el-dropdown-item>-->
                </el-dropdown-menu>
              </template>
            </el-dropdown>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <el-dialog
      v-model="remarkVisible"
      :title="$t('contact.edit_remark')"
      width="500px"
      @close="cancel"
    >
      <el-form ref="editForm" :rules="rules" :model="form" label-position="top">
        <el-form-item :label="$t('developer.name')" prop="name">
          <el-input v-model="form.name" disabled show-word-limit clearable />
        </el-form-item>
        <el-form-item :label="$t('contact.remark')" prop="remark">
          <el-input
            v-model="form.remark"
            type="textarea"
            :autosize="{ minRows: 4, maxRows: 10 }"
            maxlength="256"
            show-word-limit
            clearable
            @blur="() => (form.remark = form.remark.trim())"
          />
        </el-form-item> </el-form
      ><template #footer>
        <span class="dialog-footer">
          <el-button text @click="cancel">{{ $t("common.cancel") }}</el-button>
          <el-button type="primary" :loading="isDisabled" @click="submit()">{{
            $t("common.confirm")
          }}</el-button>
        </span></template
      >
    </el-dialog>
    <el-dialog
      v-model="rejectDeveloperVisible"
      :title="$t('common.reject')"
      width="500px"
      @close="rejectCancel"
    >
      <el-form
        ref="rejectForm"
        :rules="rejectRules"
        :model="rejectForm"
        label-position="top"
      >
        <el-form-item :label="$t('developer.name')" prop="name">
          <el-input v-model="rejectForm.name" disabled show-word-limit clearable />
        </el-form-item>
        <el-form-item :label="$t('common.reject_reason')" prop="rejectReason">
          <el-input
            v-model="rejectForm.rejectReason"
            type="textarea"
            :autosize="{ minRows: 4, maxRows: 10 }"
            maxlength="256"
            show-word-limit
            clearable
            @blur="() => (rejectForm.rejectReason = rejectForm.rejectReason.trim())"
          />
        </el-form-item> </el-form
      ><template #footer>
        <span class="dialog-footer">
          <el-button text @click="rejectCancel">{{ $t("common.cancel") }}</el-button>
          <el-button type="primary" :loading="isDisabled" @click="rejectSubmit()">{{
            $t("common.confirm")
          }}</el-button>
        </span></template
      >
    </el-dialog>
    <add-or-update
      v-if="addOrUpdateVisible"
      ref="addOrUpdate"
      @refreshDataList="getDataList"
      @close="addOrUpdateVisible = false"
    />
    <check-developer
      v-model="checkDeveloperVisible"
      ref="checkDeveloper"
      @refreshDataList="getDataList"
    />
    <developer-apply-cert
      v-if="applyCertVisible"
      ref="applyCert"
      @refreshDataList="getDataList"
      @close="applyCertVisible = false"
    />
    <registration-notice-email-manage
      v-model="noticeEmailManageVisible"
      ref="registrationNoticeEmailManage"
    />
    <check-assist-manage
      v-if="checkAssistManageVisible"
      ref="checkAssistManage"
      @close="checkAssistManageVisible = false"
    />
    <check-assist-result-list
      v-if="checkAssistResultVisible"
      ref="checkAssistResult"
      @close="checkAssistResultVisible = false"
    />
    <personal-developer-batch-import
      v-if="personalDeveloperBatchImportVisible"
      ref="personalDeveloperBatchImport"
      v-model="personalDeveloperBatchImportVisible"
      @close="personalDeveloperBatchImportVisible = false"
      @refreshDataList="getDataList"
    />
    <company-developer-batch-import
      v-if="companyDeveloperBatchImportVisible"
      ref="companyDeveloperBatchImport"
      v-model="companyDeveloperBatchImportVisible"
      @close="companyDeveloperBatchImportVisible = false"
      @refreshDataList="getDataList"
    />
    <add-developer v-model="developerAddVisible" @refreshDataList="getDataList" />
    <manage-usb-key
      v-if="manageUsbKeyVisible"
      ref="manageUsbKey"
      @close="manageUsbKeyVisible = false"
    />
    <developer-audit-record-list
      ref="developerAuditRecordList"
      :title="$t('developer.audit_record.list_title')"
      v-model="developerAuditRecordListVisible"
    />
  </div>
</template>

<script>
import TableColumnFilter from "@/components/page-setting/table-column-filter";
import { timeFilter, dateFilter } from "@/filters/index";
import { formatDate } from "@/utils/formatDate";
import { formatCountry } from "@/utils/formatCountry";
import {
  developerList,
  lockDeveloper,
  unlockDeveloper,
  deleteDeveloper,
  closeDeveloper,
  updateRemark,
  rejectDeveloper,
} from "@/api/developer";
import AddOrUpdate from "./developer-add-or-update";
import DeveloperApplyCert from "./developer-apply-cert";
import CheckDeveloper from "./check-developer";
import RegistrationNoticeEmailManage from "./components/registration-notice-email-manage";
import CheckAssistManage from "./components/check-assist-manage";
import CheckAssistResultList from "./components/check-assist-result-list";
import PersonalDeveloperBatchImport from "./components/personal-developer-batch-import";
import CompanyDeveloperBatchImport from "./components/company-developer-batch-import";
import AddDeveloper from "./components/add-developer.vue";
import ManageUsbKey from "./components/manage-usb-key";
import DeveloperAuditRecordList from "@/views/developer/components/developer-audit-record-list";
import { isAuth } from "@/utils";
import PageTitle from "@/components/PageTitle/index.vue";
export default {
  name: "Developer",
  components: {
    DeveloperAuditRecordList,
    AddOrUpdate,
    DeveloperApplyCert,
    CheckDeveloper,
    TableColumnFilter,
    RegistrationNoticeEmailManage,
    CheckAssistManage,
    CheckAssistResultList,
    PersonalDeveloperBatchImport,
    CompanyDeveloperBatchImport,
    AddDeveloper,
    ManageUsbKey,
    PageTitle,
  },

  data() {
    return {
      developerAuditRecordListVisible: false,
      manageUsbKeyVisible: false,
      developerAddVisible: false,
      settings: {
        conditions: [],
        columns: [],
      },
      form: {
        name: "",
        remark: "",
        developerId: "",
      },
      rejectForm: {
        name: "",
        rejectReason: "",
        developerId: "",
      },
      dataForm: {
        name: "",
        developerType: null,
        status: null,
      },
      remarkVisible: false,
      isDisabled: false,
      addOrUpdateVisible: false,
      applyCertVisible: false,
      checkDeveloperVisible: false,
      rejectDeveloperVisible: false,
      noticeEmailManageVisible: false,
      checkAssistManageVisible: false,
      checkAssistResultVisible: false,
      personalDeveloperBatchImportVisible: false,
      companyDeveloperBatchImportVisible: false,
      cardBindBankId: 0,
      dataList: [],
      pageNo: 1,
      pageSize: 10,
      rows: 0,
      dataListLoading: false,
      rules: {
        remark: [
          {
            required: true,
            message: this.$t("contact.remark_not_null_tip"),
            trigger: ["blur"],
          },
        ],
      },
      rejectRules: {
        rejectReason: [
          {
            required: true,
            message: this.$t("common.reject_reason_tip_empty"),
            trigger: ["blur"],
          },
        ],
      },
    };
  },
  computed: {
    statusArray() {
      return [
        { label: this.$t("developer.status_list.locked"), value: 0 },
        { label: this.$t("developer.status_list.normal"), value: 1 },
        { label: this.$t("developer.status_list.pending_review"), value: 2 },
        { label: this.$t("developer.status_list.rejected"), value: 3 },
        { label: this.$t("developer.status_list.country_examine"), value: 5 },
        { label: this.$t("developer.status_list.cert_examine"), value: 7 },
        { label: this.$t("developer.status_list.logged_off"), value: 8 },
      ];
    },
    typeArray() {
      return [
        { label: this.$t("developer.developer_type_list.personal"), value: 1 },
        { label: this.$t("developer.developer_type_list.company"), value: 2 },
      ];
    },
    settingList() {
      return {
        columns: [
          {
            title: this.$t("developer.pidType"),
            code: "pidType",
          },
          {
            title: this.$t("contact.remark"),
            code: "remark",
          },
          {
            title: this.$t("common.reject_reason"),
            code: "rejectionReason",
          },
          {
            title: this.$t("developer.pidNo"),
            code: "pidNo",
          },
          {
            title: this.$t("developer.email"),
            code: "email",
          },
          {
            title: this.$t("developer.creTime"),
            code: "creTime",
          },
        ],
      };
    },
    defaultSettings() {
      return {
        columns: [
          "email",
          "remark",
          // this.$t('common.online'),
        ],
      };
    },
  },
  mounted() {
    this.$store.commit("app/ADD_KEEP_ALIVE_LIST", "Developer");
    this.getDataList();
  },
  beforeRouteLeave(to, from, next) {
    console.log(to);
    if (to.name !== "developerInfo") {
      this.$store.commit("app/REMOVE_KEEP_ALIVE_LIST", "Developer");
    }
    next();
  },
  methods: {
    timeFilter,
    dateFilter,
    statusFilter(status) {
      const statusMap = {
        0: this.$t("developer.status_list.locked"),
        1: this.$t("developer.status_list.normal"),
        2: this.$t("developer.status_list.pending_review"),
        3: this.$t("developer.status_list.rejected"),
        5: this.$t("developer.status_list.country_examine"),
        7: this.$t("developer.status_list.cert_examine"),
        8: this.$t("developer.status_list.logged_off"),
      };
      return statusMap[status];
    },
    cancel() {
      this.$refs["editForm"].resetFields();
      this.remarkVisible = false;
    },
    rejectCancel() {
      this.$refs["rejectForm"].resetFields();
      this.rejectDeveloperVisible = false;
    },
    rejectSubmit() {
      this.$refs["rejectForm"].validate((valid) => {
        if (valid) {
          this.isDisabled = true;
          rejectDeveloper(this.rejectForm)
            .then(() => {
              this.$message.success(this.$t("common.operate_success"));
              this.getDataList();
              this.rejectDeveloperVisible = false;
              this.isDisabled = false;
              this.rejectForm = {
                name: "",
                rejectReason: "",
                developerId: "",
              };
            })
            .catch((e) => {
              this.isDisabled = false;
              this.$confirmError(e);
            });
        }
      });
    },
    submit(form) {
      this.$refs["editForm"].validate((valid) => {
        if (valid) {
          this.isDisabled = true;
          updateRemark(this.form)
            .then((data) => {
              this.$message.success(this.$t("common.operate_success"));
              this.getDataList();
              this.remarkVisible = false;
              this.isDisabled = false;
              this.form = {
                name: "",
                remark: "",
                developerId: "",
              };
            })
            .catch((e) => {
              this.isDisabled = false;
              this.$confirmError(e);
            });
        }
      });
    },
    handleDevCommand(command, data) {
      if (command === "showCheckAssistResult") {
        this.showCheckAssistResultDialog(data.developerId);
      } else if (command === "showCheckAssist") {
        this.showCheckAssistDialog(data.developerId);
      } else if (command === "info") {
        this.handleDetail(data);
        // this.addOrUpdateHandle(data, 'info')
      } else if (command === "apply") {
        this.applyCert(data);
      } else if (command === "download") {
        this.download(data);
      } else if (command === "lock") {
        this.handleLock(data.developerId);
      } else if (command === "unlock") {
        this.handleUnLock(data.developerId);
      } else if (command === "delete") {
        this.handleDelete(data.developerId);
      } else if (command === "close") {
        this.handleClose(data.developerId);
      } else if (command === "examine") {
        this.checkDeveloper(data);
      } else if (command === "reject") {
        this.rejectDeveloper(data);
      } else if (command === "remark") {
        this.form.developerId = data.developerId;
        this.form.remark = data.remark;
        if (data.developerType === 1) {
          this.form.name = data.contactName;
        } else {
          this.form.name = data.firstName;
        }
        this.remarkVisible = true;
      } else if (command === "manageUsbKey") {
        this.showManageUsbKeyDialog(data.developerId);
      } else if (command === "auditRecordList") {
        this.showDeveloperAuditRecordList(data.developerId);
      }
    },
    handleDetail(data) {
      localStorage.setItem("developer-info", JSON.stringify(data));
      this.$router.push({
        path: `/developer/developer-detail/${data.developerId}`,
      });
    },
    showHeader(label) {
      var list = this.settings["columns"];
      return list ? list.includes(label) : false;
    },
    showFormItem(label) {
      var list = this.settings["conditions"];
      return list ? list.includes(label) : false;
    },
    // 获取数据列表
    getDataList() {
      this.dataListLoading = true;
      const params = {
        pageNo: this.pageNo,
        pageSize: this.pageSize,
        developerType: this.dataForm.developerType,
        status: this.dataForm.status,
        name: this.dataForm.name,
      };
      developerList(params)
        .then((data) => {
          this.dataList = data.data;
          this.rows = data.rows;
          this.dataListLoading = false;
        })
        .catch((e) => {
          // this.$message.error(e.message)
          this.dataListLoading = false;
          this.$confirmError(e);
          console.log(`err:${JSON.stringify(e)}`);
        });
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageNo = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageNo = val;
      this.getDataList();
    },
    addOrUpdateHandle(developer, operateType) {
      this.addOrUpdateVisible = true;
      this.$nextTick(() => {
        this.$refs.addOrUpdate.init(developer, operateType);
      });
    },
    applyCert(developer) {
      this.applyCertVisible = true;
      this.$nextTick(() => {
        this.$refs.applyCert.init(developer);
      });
    },
    download(developer) {
      if (developer) {
        const link = document.createElement("a");
        link.style.display = "none";
        link.setAttribute("target", "tempframe");
        link.setAttribute(
          "href",
          import.meta.env.VITE_APP_BASE_API +
            "/online/developer-admin/developer/" +
            developer.developerId +
            "/cert"
        );
        link.click();
      }
    },
    checkDeveloper(developer) {
      this.checkDeveloperVisible = true;
      this.$nextTick(() => {
        this.$refs.checkDeveloper.init(developer);
      });
    },
    rejectDeveloper(developer) {
      this.rejectForm.developerId = developer.developerId;
      if (developer.developerType === 1) {
        this.rejectForm.name = developer.contactName;
      } else {
        this.rejectForm.name = developer.firstName;
      }
      this.rejectDeveloperVisible = true;
    },
    formatDate(cellValue, fmt) {
      return formatDate(cellValue, fmt);
    },
    formatCountry(row, column, cellValue, index) {
      return formatCountry(cellValue);
    },
    handleLock(developerId) {
      this.$confirm(this.$t("developer.confirm_lock"), "", {
        confirmButtonText: this.$t("common.confirm"),
        cancelButtonText: this.$t("common.cancel"),
        type: "warning",
      }).then(() => {
        this.dataListLoading = true;
        lockDeveloper(developerId)
          .then((data) => {
            this.dataListLoading = false;
            this.getDataList();
          })
          .catch((e) => {
            this.dataListLoading = false;
            this.$confirmError(e);

            console.log(`err:${JSON.stringify(e)}`);
          });
      });
    },
    handleUnLock(developerId) {
      this.$confirm(this.$t("developer.confirm_unlock"), "", {
        confirmButtonText: this.$t("common.confirm"),
        cancelButtonText: this.$t("common.cancel"),
        type: "warning",
      }).then(() => {
        this.dataListLoading = true;
        unlockDeveloper(developerId)
          .then((data) => {
            this.dataListLoading = false;
            this.getDataList();
          })
          .catch((e) => {
            this.$confirmError(e);

            this.dataListLoading = false;
            console.log(`err:${JSON.stringify(e)}`);
          });
      });
    },
    handleDelete(developerId) {
      this.$confirm(this.$t("developer.confirm_delete"), "", {
        confirmButtonText: this.$t("common.confirm"),
        cancelButtonText: this.$t("common.cancel"),
        type: "warning",
      }).then(() => {
        this.dataListLoading = true;
        deleteDeveloper(developerId)
          .then((data) => {
            this.dataListLoading = false;
            this.getDataList();
          })
          .catch((e) => {
            this.$confirmError(e);

            this.dataListLoading = false;
            console.log(`err:${JSON.stringify(e)}`);
          });
      });
    },
    handleClose(developerId) {
      this.$confirm(this.$t("developer.confirm_close"), "", {
        confirmButtonText: this.$t("common.confirm"),
        cancelButtonText: this.$t("common.cancel"),
        type: "warning",
      }).then(() => {
        this.dataListLoading = true;
        closeDeveloper(developerId)
          .then((data) => {
            this.dataListLoading = false;
            this.getDataList();
          })
          .catch((e) => {
            this.$confirmError(e);
            this.dataListLoading = false;
            console.log(`err:${JSON.stringify(e)}`);
          });
      });
    },
    manageNoticeEmail() {
      this.noticeEmailManageVisible = true;
      this.$nextTick(() => {
        this.$refs.registrationNoticeEmailManage.init();
      });
    },
    showCheckAssistDialog(developerId) {
      this.checkAssistManageVisible = true;
      this.$nextTick(() => {
        this.$refs.checkAssistManage.init(developerId);
      });
    },
    showCheckAssistResultDialog(developerId) {
      this.checkAssistResultVisible = true;
      this.$nextTick(() => {
        this.$refs.checkAssistResult.init(developerId);
      });
    },
    showPersonalDeveloperBatchImportDialog() {
      this.personalDeveloperBatchImportVisible = true;
      this.$nextTick(() => {
        this.$refs.personalDeveloperBatchImport.init();
      });
    },
    showCompanyDeveloperBatchImportDialog() {
      this.companyDeveloperBatchImportVisible = true;
      this.$nextTick(() => {
        this.$refs.companyDeveloperBatchImport.init();
      });
    },
    handleCommandImport(type) {
      if (type === "Personal") {
        this.showPersonalDeveloperBatchImportDialog();
      } else if (type === "Company") {
        this.showCompanyDeveloperBatchImportDialog();
      }
    },
    handleCommandAdd() {
      this.developerAddVisible = true;
    },
    showManageUsbKeyDialog(developerId) {
      this.manageUsbKeyVisible = true;
      this.$nextTick(() => {
        this.$refs.manageUsbKey.init(developerId);
      });
    },
    showDeveloperAuditRecordList(developerId) {
      this.developerAuditRecordListVisible = true;
      this.$nextTick(() => {
        this.$refs.developerAuditRecordList.init(developerId);
      });
    },
    isAuth,
  },
};
</script>
<style lang="scss" scoped></style>
